package com.example.demo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 配置直接交换机 创建用户登录信息队列 保存用户登录token 或cookie
 */

@Configuration
public class DirectRabbitConfig {

    private final static String userLogin="userlogin";
    private final static String userExchange="userLoginExchange";

    @Bean
    public Queue userLogin(){
        return new Queue(userLogin);
    }

    @Bean
    DirectExchange userLoginExchange(){
        return new DirectExchange(userExchange);
    }

    @Bean
    Binding userLoginBinding(){
        return BindingBuilder.bind(userLogin()).to(userLoginExchange()).with("userLogin");
    }

}
